class MyArray{
  constructor(x){
    this.array=new Array(x)
    this.x=x
    this.size=0
  }
  insert(index,element){
    if(index<0 || index>this.size){
      throw new Error("超出数组实际元素范围！");
    }
    if(this.size >=this.x){
      this.resize();
    }
    for(let i=this.size-1; i>=index; i--){
      console.log(this.array[i])
      this.array[i+1] = this.array[i];
    }
    this.array[index] = element;
    this.size++;
  }
  resize(){
    this.x+=this.x
  }
  delete(index){
    if(index<0 || index>=this.size){
      throw new Error("超出数组实际元素范围！");
    }
    for(let i=index; i<this.size-1; i++){
      this.array[i] = this.array[i+1];
    }
    this.array.pop()
    this.size--;
  }
  output(){
    for(let i=0; i<this.size; i++){
      console.log(this.array[i])
    }
  }
}

let myArray = new MyArray(3)

myArray.insert(0,3);
myArray.insert(1,7);
myArray.insert(2,999);
myArray.insert(3,2);
myArray.insert(4,1);
myArray.insert(5,66);
myArray.delete(0);
myArray.output();